home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / sr / info.lha / info-sr.1992 / 000015_olsson@cs.ucdavis.edu _Thu Oct 8 00:01:38 1992.msg < prev    next >
Text File  |  1993-07-24  |  2KB  |  62 lines

  1. Received: from ivy.cs.ucdavis.edu by optima.cs.arizona.edu (5.65c/15) via SMTP
  2.     id AA16078; Thu, 8 Oct 1992 00:01:58 MST
  3. Received: by ivy.cs.ucdavis.edu (5.57/UCD.CS.2.0)
  4.     id AA22242; Thu, 8 Oct 92 00:01:38 -0700
  5. Date: Thu, 8 Oct 92 00:01:38 -0700
  6. From: olsson@cs.ucdavis.edu (Ron Olsson)
  7. Message-Id: <9210080701.AA22242@ivy.cs.ucdavis.edu>
  8. To: timbomb@cs.uq.oz.au
  9. Cc: info-sr@cs.arizona.edu
  10. In-Reply-To: Tim Mansfield's message of Thu, 08 Oct 92 14:43:46 +1000 <9210080443.AA06080@uqcspe.cs.uq.oz.au>
  11. Subject: Possibly dumb crash question...
  12.  
  13. The problem is in the code
  14.  
  15.      proc bank() returns p
  16.        op bankput: put
  17.        var pget: cap get
  18.  
  19.        p:= bankput
  20.        reply
  21.        in bankput(banktest, pget) ->
  22.      write("banktest", banktest)
  23.        ni
  24.        send pget(5)    # memory fault here
  25.      end
  26.  
  27. The input statement's two parameters -- banktest and pget -- have
  28. values from the invocation of bankput; their scope is the input
  29. statement; they disappear at the ni.  The value of variable pget
  30. (different from parameter pget) is unchanged by the input statement.
  31. Since variable pget was never initialized, its value is unknown, so
  32. the send invocation is erroneous.  By chance, the particular (garbage)
  33. value of pget is causing the problem you saw.  (More typically, it
  34. would cause a "null invocation" error.)
  35.  
  36. You probably meant to code the above as
  37.  
  38.      proc bank() returns p
  39.        op bankput: put
  40.        #### no longer needed: var pget: cap get
  41.  
  42.        p:= bankput
  43.        reply
  44.        in bankput(banktest, pget) ->
  45.      write("banktest", banktest)
  46.          send pget(5)
  47.        ni
  48.      end
  49.  
  50. or as
  51.  
  52.      proc bank() returns p
  53.        op bankput: put
  54.        var pget: cap get
  55.        var banktest: int  #### new decl
  56.  
  57.        p:= bankput
  58.        reply
  59.        receive bankput(banktest, pget)
  60.        write("banktest", banktest)
  61.        send pget(5)
  62.      end